/*	WWW Library functions
**	---------------------
**
** This links the WWW library to the NeXt world.
**
**  Types to be equated:   HyperText		HText
**			   Anchor		Anchor
**			   HTStyle		HTStyle  same?
*/

#import "HyperText.h"		/* NextStep style */

/*	Exports
*/ 
PUBLIC HText * HTMainText = 0;		/* Equivalent of main window */
PUBLIC HTParentAnchor * HTMainAnchor = 0;	/* Anchor for HTMainText */



/*				B U I L D I N G
*/

PUBLIC HText * HText_new (HTParentAnchor *anchor)
{
    HText * HT = [HyperText newAnchor:anchor];
    HTMainAnchor = anchor;
    HTMainText = HT;
    
    [HT setupWindow];			
    [HT setEditable:NO];			/* This is read-only data */

    return HT;
}

PUBLIC HText * HText_new2 (HTParentAnchor *anchor, HTStream* sink)
{
    HText * HT = [HyperText newAnchor:anchor];
    HTMainAnchor = anchor;
    HTMainText = HT;
    
    [HT setupWindow];			
    [HT setEditable:NO];			/* This is read-only data */

    return HT;
}

PUBLIC void HText_free(HText * me)
{
    [me free];
}

PUBLIC void HText_beginAppend(HText * me)
{
    [me appendBegin];
}

PUBLIC void HText_endAppend(HText * me)
{
    [me appendEnd];
    if (HTList_indexOf(
    	HTAnchor_methods([me nodeAnchor]),
	HTAtom_for("PUT")) != (-1)) {
            [me setEditable:YES];	
    }
}

PUBLIC void HText_setStyle(HText * me, HTStyle * style)
{
    [me appendStyle:style];
}

PUBLIC void HText_appendCharacter(HText * me, char ch)
{
    [me appendCharacter:ch];
}

PUBLIC void HText_appendText(HText * me, const char * str)
{
    [me appendText:str];
}

PUBLIC void HText_appendParagraph(HText * me)
{
    [me appendCharacter:'\n'];
}

PUBLIC void HText_beginAnchor(HText * me, HTChildAnchor * anc)
{
    [me appendBeginAnchor:anc];
}

PUBLIC void HText_endAnchor(HText * me)
{
    [me appendEndAnchor];
}

/*				B R O W S I N G
*/

PUBLIC BOOL HText_select(HText * me)
{
    id status = [me selectAnchor:NULL];
    if (!status) return NO;
    
    HTMainAnchor = [me nodeAnchor];
    HTMainText = me;
    return YES;
}

PUBLIC BOOL HText_selectAnchor(HText * me, HTChildAnchor * anchor)
{
    id status = [me selectAnchor:anchor];
    if (!status) return NO;
    
    HTMainAnchor = [me nodeAnchor];
    HTMainText = me;
    return YES;
}

/*		editing functions not supported
*/
